//
//  BaseViewController.m
//  WTSlideToBackDemo
//
//  Created by wintel on 16/8/5.
//  Copyright © 2016年 wintelsui. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (void)setLeftButtonWithImageName:(NSString *)imageName{
    UIButton *tmpLeftButton = [UIButton buttonWithType:UIButtonTypeCustom];
    
    tmpLeftButton.frame = CGRectMake(0, 0, 44, 44);
    tmpLeftButton.showsTouchWhenHighlighted = NO;
    tmpLeftButton.exclusiveTouch = YES;
    
    [tmpLeftButton setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [tmpLeftButton addTarget:self action:@selector(leftButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    
    self.leftButton = tmpLeftButton;
    UIBarButtonItem *leftButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tmpLeftButton];
    
    [self.navigationItem setLeftBarButtonItem:leftButtonItem];
}

-(void)leftButtonPressed:(id)action
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (BOOL)isEnableSlideToBack{
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
